package com.example.howard.mytcpclient;


import android.content.Context;

import java.util.ArrayList;
import java.util.List;

public class ShowClientView {

    private List<String> logContentList = new ArrayList<>();
//ListView最多显示五行
    private final static int DEFAULT_MAX_CONTENT_COUNT = 3;
    private int maxContentCount = DEFAULT_MAX_CONTENT_COUNT;

    private Context context;

    public ShowClientView(Context context){

        this.context = context;



    }



    public void setMaxContentCount(int maxContentCount){

        this.maxContentCount = maxContentCount > 0 ? maxContentCount : DEFAULT_MAX_CONTENT_COUNT;

    }

    public int getMaxContentCount(){

        return this.maxContentCount;
    }


    public synchronized List<String> getCurrentContentList(){

        return logContentList;
    }
    //添加内容
    public synchronized void addContent(String content){

        int currentCount = logContentList.size();

        if(currentCount + 1 > maxContentCount){

            logContentList.remove(0);
        }

        logContentList.add(content);
    }

    public synchronized void clear(){

        logContentList.clear();
    }



}
